<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="application/javascript" src="/js/jquery-1.4.4.min.js"></script>
    <title>Title</title>
</head>
<body>
<input type="button" value="ajax" onclick="cross_origin();">
<input type="button" value="ajax2" onclick="cross_origin2();">

<script type="application/javascript">

    function cross_origin(){
        $.ajax({
            type:"get",
            url:"http://localhost:8081/origin/test1",
            //contentType:"",//请求参数utf-8
            dataType: "application/json;charset=UTF-8",//响应的时候编码 utf-8
            xhrFields: {
                // 跨域携带cookie
                withCredentials: true
            },
            success:function(ret){
                console.log("ret:"+ret);
            }
        });
    }

    function cross_origin2(){
        $.ajax({
            type:"get",
            url:"http://localhost:8080/origin/test2",
            xhrFields: {
                // 跨域携带cookie
                withCredentials: true
            },
            success:function(ret){
                console.log("ret:"+ret);
            }
        });
    }
</script>

</body>
</html>
